package br.com.naybee.framework.client.componente.gwt.web;

import com.google.gwt.dom.client.ButtonElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;

public class Button extends ComplexPanel implements HasClickHandlers {

	private ButtonElement buttonElement = DOM.createButton().cast();

	public Button() {
		setElement(buttonElement);
	}

	public void setType(String type) {
		buttonElement.setAttribute("type", type);
	}

	public String getType(String type) {
		return buttonElement.getAttribute("type");
	}

	public void setClassName(String className) {
		buttonElement.setClassName(className);
	}

	public String getClassName() {
		return buttonElement.getClassName();
	}

	public void setText(String text) {
		buttonElement.setInnerText(text);
	}

	public String getText() {
		return buttonElement.getInnerText();
	}

	public HandlerRegistration addClickHandler(ClickHandler handler) {
		return addDomHandler(handler, ClickEvent.getType());
	}

}
